package systemInputOutput;

import geometricElement.GeometricElement;
import robot.Robot;
import java.util.LinkedList;


public class SystemIO implements IOinterface {
	
	// methods
	public int[] getGroundSize() {
		int[] size = new int[2];
		size[0] = Console.readInt("Please enter ground's height\n");
		size[1] = Console.readInt("Please enter ground's width\n");
		return size;
	}
	
	/**
	 * Asks the user for wanted option and returns it
	 * @return Option given by user
	 */
	public int getOption() {
		return Console.readInt("Please insert 1 to place new robots on the ground, 2 to place new geometric elements or 3 to start the pick up\n");
	}
	
	/**
	 * Asks the user for wanted position (x and y coordinates) for the new object.
	 * Returns an array of 2 ints- the first entry is x-axis coordinate and the second is y-axis coordinate 
	 * @return Int array of size 2, holding the position
	 */
	public int[] getObjectPosition() {
		int[] position = new int[2];
		position[0] = Console.readInt("Please insert x axis coordinate\n");
		position[1] = Console.readInt("Please insert y axis coordinate\n");
		return position;
	}
	
	public double getRobotBasket() {
		return Console.readDouble("Please enter basket capacity for the robot\n");
	}
	
	/**
	 * Prints message to ask the user for the new object's type
	 * @return New object's property
	 */
	public double getElementProperty() {
		return Console.readDouble("Please insert property. Circle's property is radius, Square / PerfectTriangle's property is side length\n");
	}
	
	/**
	 * Prints message to ask the 
	 * @return New object's type 
	 */
	public String getElementType() {
		return Console.readString("Please insert type. Possible types: Circle, Square, PerfectTriangle\n");
	}
	
	public int askIfContinueAdding(String type) {
		return Console.readInt(String.format("If you want to add any more %ss, insert 1. Otherwise, 0.\n", type));
	}
	
	public int askToAddGeoElements() {
		return Console.readInt("Please insert 1 if you wish to add geometric elements to the ground");
	}
	
	/**
	 * Prints error given message to the user
	 * @param msg- Error message to be printed
	 */
	public void notifyErrorMsg(String msg) {
		System.out.println(msg);
	}

	/**
	 * If given list is empty, notifies user that all geometric elements were picked.
	 * Otherwise, scans given list and prints each element. 
	 * @param listToPrint- list of geometric elements that were not picked
	 */
	public void printNonPickedGeoElements(LinkedList<GeometricElement> listToPrint) {
		// check if list is empty
		if (listToPrint.isEmpty()) {
			// notify user that all elements were picked
			System.out.println("No geometric element remained non-picked :)");
			return;
		}
		// scan list and print each element
		System.out.println("Could not pick up the following geomteric elements:");
		for (GeometricElement currElement : listToPrint) {
			System.out.println(currElement);
		}
		return;
	}
	
	/**
	 * If given list is empty, notifies user that there is no statistics to print.
	 * Otherwise, scans given list and prints each robot.
	 * @param listToPrint- list of robots
	 */
	public void printRobotsStats(LinkedList<Robot> listToPrint) {
		// check if list is empty
		if (listToPrint.isEmpty()) {
			// notify user that there is not any data to print
			System.out.println("Cannot print statistics since no robots were created.");
			return;
		}		
		// scan list and print each robot
		System.out.println("Printing robots' statistics:");
		for (Robot currRobot : listToPrint) {
			System.out.println(currRobot);
		}
	}
}
